<style>
.h44{
	height:44px;
}
.weui_mask_transition {
    display: none;
    position: fixed;
    z-index: 1;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.54);
    -webkit-transition: background .3s;
    transition: background .3s;
    bottom: 0px;
    z-index: 10;
}
.weui_actionsheet_toggle {
    -webkit-transform: translate(0, 0);
    transform: translate(0, 0);
    z-index: 11;
}
</style>
<div class="page">
	<div class="hd">
		<div class="tabs tabs-striped tabs-top" style="top:0px;position:fixed;">
			<a class="tab-item {if !isset($status)}active{/if}" data-pjax href="{php echo $this->createMobileUrl('home_order')}">全部</a>
			<a class="tab-item {if $status == 1}active{/if}" data-pjax href="{php echo $this->createMobileUrl('home_order',array('status'=>1))}">等待中</a>
			<a class="tab-item {if $status == 2}active{/if}" data-pjax href="{php echo $this->createMobileUrl('home_order',array('status'=>2))}">已被抢</a>
			<a class="tab-item {if $status == 3}active{/if}" data-pjax href="{php echo $this->createMobileUrl('home_order',array('status'=>3))}">已完成</a>
			<a class="tab-item {if $status == 4}active{/if}" data-pjax href="{php echo $this->createMobileUrl('home_order',array('status'=>4))}">已打款</a>
		</div>
		<div class="h44"></div>
		<div class="list">
			{loop $orders $order}
			<div class="item item-avatar" data-id="{php echo $order['id']}">
				<img src="{$order['user']['avatar']}" alt="{$order['user']['nickname']}" />
				<h2 class="title">{$order['user']['nickname']}</h2>
				<p style="white-space: normal;color:gray;">{$order['desc']}</p>
				<span>{$order['create_time']}</span>
				{if $order['status'] == 1}
					<i class="badge badge-assertive" style="margin-top: -10px;">等待中</i>
				{else if $order['status'] == 2}
					<i class="badge badge-royal" style="margin-top: -10px;">已被抢</i>
				{else if $order['status'] == 3}
					<i class="badge badge-positive" style="margin-top: -10px;">已完成</i>
				{else if $order['status'] == 4}
					<i class="badge badge-dark" style="margin-top: -10px;">已打款</i>
				{else}
					<i class="badge badge-stable" style="margin-top: -10px;">支付失败</i>
				{/if}
			</div>
			{/loop}
		</div>
	</div>
</div>
<script>
require(['jquery','core'],function($,core){
	$('#footer').show();
	
	//data-pjax href="{if $order['status'] == 0}{else if $order['status'] == 1}{php echo $this->createMobileUrl('manage',array('id'=>$order['id']))}{else}{php echo $this->createMobileUrl('home_detail',array('id'=>$order['id']))}{/if}"
	$('.list .item').click(function(){
		var id = $(this).data('id');
		var _this = $(this);
		core.actionSheet([{
            label: '管理任务',
            onClick: function () {
            	window.location.href = "{php echo $this->createMobileUrl('manage')}&id="+id;
            }
        },{
            label: '立即结款',
            onClick: function () {
            	core.ok("您确认此任务已顺利完成，现在就给服务人员结款么？",function(){
            		core.post('home_finish',{id:id},function(data){
                		if(data.result == 0){
                			core.cancel(data.message,function(){
                				window.location.href = "{php echo $this->createMobileUrl('home_order')}"+"&status="+"{php echo $_GPC['status']}"
                			});
                		}else{
                			core.cancel(data.message,function(){});
                		}
                	});
            	});
            }
        }, {
            label: '删除任务',
            onClick: function () {
            	core.ok("您确定要删除此任务么？删除任务将清空一切活动相关数据！",function(){
            		core.post('home_delete',{id:id},function(data){
                		if(data.result == 0){
                			core.cancel(data.message,function(){
                				window.location.href = "{php echo $this->createMobileUrl('home_order')}&status="+"{php echo $_GPC['status']}";
                			});
                		}else{
                			core.cancel(data.message,function(){});
                		}
                	});
            	});
            }
        }]);
	});
	
});
</script>